<html xmlns:th="http://www.thymeleaf.org" xmlns:layout="http://www.ultraq.net.nz/web/thymeleaf/layout" layout:decorator="base/layout.html">


    <!-- start: Content -->
    <div layout:fragment="content" class="main ">

        <div class="row">
            <div class="col-lg-12">
                <ol class="breadcrumb">
                    <li><i class="fa fa-home"></i><a href="index.html">主页</a></li>

                    <li><i class="fa fa-indent"></i>添加教师信息</li>
                </ol>
            </div>
        </div>

        <div class="row">
            <div class="col-lg-12">
                <div class="panel panel-default">
                    <div class="panel-heading">
                        <h2><i class="fa fa-indent red"></i><strong>添加教师信息</strong></h2>
                    </div>
                    <div class="panel-body">
                        <form id="modularForm" action="" method="post" enctype="multipart/form-data" class="form-horizontal ">

                            <div class="form-group">
                                <label class="col-md-3 control-label" for="text-input1">姓名</label>
                                <div class="col-md-9">
                                    <input type="text" id="text-input1" name="name" class="form-control" placeholder="姓名">
                                    <span class="help-block">请输入姓名</span>
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="col-md-3 control-label" >职业</label>
                                <div class="col-md-9">
                                    <select id="majorInfo" name="major" class="form-control" size="1">
                                    </select>
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="col-md-3 control-label" for="text-input3">联系方式</label>
                                <div class="col-md-9">
                                    <input type="text" id="text-input3" name="phoneNum" class="form-control" placeholder="联系方式">
                                    <span class="help-block">请输入联系方式</span>
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="col-md-3 control-label" for="text-input3">入职时间</label>
                                <div class="col-md-9">
                                    <input type="text" id="majorDate" name="majorDate" readonly class="form-control date-picker" placeholder="入职时间">
                                    <span class="help-block">请选择入职时间</span>
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="col-md-3 control-label" for="text-input3">附件上传</label>
                                <div class="col-md-9">

                                    <input type="file" name="utilFile" />

                                </div>
                            </div>



                            <br>

                    </div>
                    <div class="panel-footer">
                        <button id="submitBtn" type="submit" class="btn btn-sm btn-success"><i class="fa fa-dot-circle-o"></i> 提交</button>
                        <button type="reset" class="btn btn-sm btn-danger"><i class="fa fa-ban"></i>重置</button>
                    </div>
                    </form>
                </div>
            </div>


        </div><!--/.row-->

        <script>
            //当页面初始化的时候，首次加载的函数
            $(document).ready(function () {
                //加载时间控件
                setDatePicker("#majorDate")
                //你想加载哪个函数，你就写在这个里面就可以
                initMajorInfo();
            });

            //加载职业的下拉框内容，用AJAX技术去实现的
            function initMajorInfo(){
                //往select下拉框去追加内容
                $('#majorInfo').append("<option value=-1> 请选择 </option>");

                $.ajax({
                    url: '../major/selectMajor',
                    type: 'get',
                    datatype: 'json',
                    data: {},
                    success: function(data){
                        //访问成功以后，执行这里面的内容
                        for (let i in data) {

                            $('#majorInfo').append("<option value="+data[i].id+"> "+data[i].name+" </option>")
                        }
                    }
                })
            }
            //利用jquery.form.js这个组件 去实现 页面的 附件上传
            $('#modularForm').submit(function (){
                $('#modularForm').ajaxSubmit({
                    url: 'add',
                    type: 'post',
                    success:function (data) {
                        layer.msg("添加成功");
                        setTimeout(function () {
                            window.location = ("teacher")
                        },1500);
                    }
                })
                return false;
            });
        </script>
    </div>